<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta name="format-detection" content="telephone=no"/>
    <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
    <meta name="viewport"
          content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi"/>
    <meta name="msapplication-tap-highlight" content="no"/>
    <title>login</title>
    <!--=S assets=-->
    <link rel="stylesheet" type="text/css" href="css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="css/main.css"/>
    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/k/seed-min.js"></script>
    <script type="text/javascript" src="js/global.js"></script>
    <!--=E assets=-->
</head>
<body>
<div id="page">
    <div id="content">
        <div class="layout">
            <!--=S header =-->
            <div id="header">
                <a href="#" id="J_sideBarBtn" class="bar-btn back-btn fl">
                </a>
                <a href="#" id="J_attetion" class="bar-btn text-btn rl">
                    注册
                </a>
                    <span class="title">
                        登录
                    </span>
            </div>
            <!--=E header =-->

            <!--=S login-mod =-->
            <link rel="stylesheet" type="text/css" href="css/login-mod.css"/>
            <div class="login-mod">
                <div class="login-bd">
                    <form id="J_form">
                        <div class="login-texts">
                            <p><input class="text" type="text" name="phone" placeholder="手机号"/></p>

                            <p><input class="text" type="password" name="password" placeholder="密码"/></p>
                        </div>
                        <p class="tool-bar">
                            <button class="sub-big-Button disabled" disabled id="J_loginButton" type="submit">
                                登录
                            </button>
                        </p>
                        <p>
                            <a href="#" id="J_forgetPwd" class="forget-pwd">忘记密码？</a>
                        </p>
                    </form>
                </div>
            </div>
            <!--=E login-mod =-->

        </div>
    </div>

</div>
<script>
    document.addEventListener('deviceready', function () {
        //登陆
        KISSY.use('dom,event,com/login', function (S, DOM, Event, Login) {
            var form = DOM.get("#J_form"),
                    btn = DOM.get("#J_loginButton");

            var phone = form.phone, pwd = form.password;

            Event.on([phone, pwd], 'valuechange', S.buffer(checkIpt, 300, this));

            Event.on(form, 'submit', function (ev) {
                ev.halt();
                Login.login(phone.value, pwd.value);
            });

            //返回按钮
            var prevUrl = localStorage.prevUrl || 'index.html';
            DOM.attr("#J_sideBarBtn", 'href', prevUrl);

            function checkIpt() {
                if (phone.value == '' || pwd.value == '') {
                    DOM.attr(btn, 'disabled', 'disabled');
                    DOM.addClass(btn, 'disabled');
                } else {
                    DOM.removeAttr(btn, 'disabled');
                    DOM.removeClass(btn, 'disabled');
                }
            }
        });
    }, false);
</script>
</body>
</html>
